package com.sthz.facepay.mapper;

import com.sthz.facepay.model.Store;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

public interface StoreMapper {
    @Delete({
        "delete from st_store",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into st_store (id, mid, ",
        "cid, name, address, ",
        "phone, number, province, ",
        "city, remark, state, ",
        "pay_order_describe, picture, ",
        "code, code_money, ",
        "code_describe)",
        "values (#{id,jdbcType=INTEGER}, #{mid,jdbcType=INTEGER}, ",
        "#{cid,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, ",
        "#{phone,jdbcType=VARCHAR}, #{number,jdbcType=VARCHAR}, #{province,jdbcType=VARCHAR}, ",
        "#{city,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{state,jdbcType=TINYINT}, ",
        "#{pay_order_describe,jdbcType=VARCHAR}, #{picture,jdbcType=VARCHAR}, ",
        "#{code,jdbcType=VARCHAR}, #{code_money,jdbcType=DOUBLE}, ",
        "#{code_describe,jdbcType=VARCHAR})"
    })
    int insert(Store record);

    @InsertProvider(type=StoreSqlProvider.class, method="insertSelective")
    int insertSelective(Store record);

    @Select({
        "select",
        "id, mid, cid, name, address, phone, number, province, city, remark, state, pay_order_describe, ",
        "picture, code, code_money, code_describe",
        "from st_store",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="meid", property="meid", jdbcType=JdbcType.INTEGER),
        @Result(column="trid", property="trid", jdbcType=JdbcType.INTEGER),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="number", property="number", jdbcType=JdbcType.VARCHAR),
        @Result(column="province", property="province", jdbcType=JdbcType.VARCHAR),
        @Result(column="city", property="city", jdbcType=JdbcType.VARCHAR),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR),
        @Result(column="state", property="state", jdbcType=JdbcType.TINYINT),
        @Result(column="pay_order_describe", property="pay_order_describe", jdbcType=JdbcType.VARCHAR),
        @Result(column="picture", property="picture", jdbcType=JdbcType.VARCHAR),
        @Result(column="code", property="code", jdbcType=JdbcType.VARCHAR),
        @Result(column="code_money", property="code_money", jdbcType=JdbcType.DOUBLE),
        @Result(column="code_describe", property="code_describe", jdbcType=JdbcType.VARCHAR)
            /*,
        @Result(column="meid", property="member", one=@One(select="com.sthz.facepay.mapper.MemberMapper.getById",fetchType = FetchType.EAGER)),
        @Result(column="trid", property="card", one=@One(select="com.sthz.facepay.mapper.Cardapper.getById",fetchType = FetchType.EAGER))*/
    })
    Store selectByPrimaryKey(Integer id);

    @UpdateProvider(type=StoreSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Store record);

    @Update({
        "update st_store",
        "set mid = #{mid,jdbcType=INTEGER},",
          "cid = #{cid,jdbcType=INTEGER},",
          "name = #{name,jdbcType=VARCHAR},",
          "address = #{address,jdbcType=VARCHAR},",
          "phone = #{phone,jdbcType=VARCHAR},",
          "number = #{number,jdbcType=VARCHAR},",
          "province = #{province,jdbcType=VARCHAR},",
          "city = #{city,jdbcType=VARCHAR},",
          "remark = #{remark,jdbcType=VARCHAR},",
          "state = #{state,jdbcType=TINYINT},",
          "pay_order_describe = #{pay_order_describe,jdbcType=VARCHAR},",
          "picture = #{picture,jdbcType=VARCHAR},",
          "code = #{code,jdbcType=VARCHAR},",
          "code_money = #{code_money,jdbcType=DOUBLE},",
          "code_describe = #{code_describe,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Store record);
}